package com.appspot.bibtable.servlet;

import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

public class PathQueryHttpServlet extends HttpServlet
{
	private static final Logger logger = Logger.getLogger(PathQueryHttpServlet.class.getName());

	protected Key getKey(HttpServletRequest request)
	{
		String[] path = request.getRequestURI().substring(1).split("/");
		if (path.length == 1)
		{
			logger.severe("Illegal request URI (contains only one slash). Check web.xml.");
			return null;
		}
		return KeyFactory.stringToKey(path[1]);
	}
}
